﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace DataConvertLib
{
	/// <summary>
	/// 字节数组类型数据转换类
	/// </summary>
	// Token: 0x02000004 RID: 4
	[Description("字节数组类型数据转换类")]
	public class ByteArrayLib
	{
		/// <summary>
		/// 根据起始地址和长度自定义截取字节数组
		/// </summary>
		/// <param name="data">字节数组</param>
		/// <param name="start">开始字节</param>
		/// <param name="length">截取长度</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600001F RID: 31 RVA: 0x00002530 File Offset: 0x00000730
		[Description("根据起始地址和长度自定义截取字节数组")]
		public static byte[] GetByteArrayFromByteArray(byte[] data, int start, int length)
		{
			bool flag = start < 0;
			if (flag)
			{
				throw new ArgumentException("开始索引不能为负数");
			}
			bool flag2 = length <= 0;
			if (flag2)
			{
				throw new ArgumentException("长度必须为正数");
			}
			bool flag3 = data.Length < start + length;
			if (flag3)
			{
				throw new ArgumentException("字节数组长度不够或开始索引太大");
			}
			byte[] array = new byte[length];
			Array.Copy(data, start, array, 0, length);
			return array;
		}

		/// <summary>
		/// 根据起始地址自定义截取字节数组
		/// </summary>
		/// <param name="data">字节数组</param>
		/// <param name="start">开始字节</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000020 RID: 32 RVA: 0x00002598 File Offset: 0x00000798
		[Description("根据起始地址自定义截取字节数组")]
		public static byte[] GetByteArrayFromByteArray(byte[] data, int start)
		{
			return ByteArrayLib.GetByteArrayFromByteArray(data, start, data.Length - start);
		}

		/// <summary>
		/// 从字节数组中截取2个字节,并按指定字节序返回
		/// </summary>
		/// <param name="value">字节数组</param>
		/// <param name="start">开始索引</param>
		/// <param name="dataFormat">字节顺序，默认为ABCD</param>
		/// <returns>字节数组</returns> 
		// Token: 0x06000021 RID: 33 RVA: 0x000025B8 File Offset: 0x000007B8
		[Description("从字节数组中截取2个字节,并按指定字节序返回")]
		public static byte[] Get2BytesFromByteArray(byte[] value, int start, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] byteArrayFromByteArray = ByteArrayLib.GetByteArrayFromByteArray(value, start, 2);
			byte[] result;
			switch (dataFormat)
			{
			case DataFormat.ABCD:
			case DataFormat.CDAB:
				result = byteArrayFromByteArray.Reverse<byte>().ToArray<byte>();
				break;
			case DataFormat.BADC:
			case DataFormat.DCBA:
				result = byteArrayFromByteArray;
				break;
			default:
				result = byteArrayFromByteArray;
				break;
			}
			return result;
		}

		/// <summary>
		/// 从字节数组中截取4个字节,并按指定字节序返回
		/// </summary>
		/// <param name="value">字节数组</param>
		/// <param name="start">开始索引</param>
		/// <param name="dataFormat">字节顺序，默认为ABCD</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000022 RID: 34 RVA: 0x00002604 File Offset: 0x00000804
		[Description("从字节数组中截取4个字节,并按指定字节序返回")]
		public static byte[] Get4BytesFromByteArray(byte[] value, int start, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] byteArrayFromByteArray = ByteArrayLib.GetByteArrayFromByteArray(value, start, 4);
			byte[] array = new byte[4];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
				array[0] = byteArrayFromByteArray[3];
				array[1] = byteArrayFromByteArray[2];
				array[2] = byteArrayFromByteArray[1];
				array[3] = byteArrayFromByteArray[0];
				break;
			case DataFormat.BADC:
				array[0] = byteArrayFromByteArray[2];
				array[1] = byteArrayFromByteArray[3];
				array[2] = byteArrayFromByteArray[0];
				array[3] = byteArrayFromByteArray[1];
				break;
			case DataFormat.CDAB:
				array[0] = byteArrayFromByteArray[1];
				array[1] = byteArrayFromByteArray[0];
				array[2] = byteArrayFromByteArray[3];
				array[3] = byteArrayFromByteArray[2];
				break;
			case DataFormat.DCBA:
				array = byteArrayFromByteArray;
				break;
			}
			return array;
		}

		/// <summary>
		/// 从字节数组中截取8个字节,并按指定字节序返回
		/// </summary>
		/// <param name="value">字节数组</param>
		/// <param name="start">开始索引</param>
		/// <param name="dataFormat">字节顺序，默认为ABCD</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000023 RID: 35 RVA: 0x00002698 File Offset: 0x00000898
		[Description("从字节数组中截取8个字节,并按指定字节序返回")]
		public static byte[] Get8BytesFromByteArray(byte[] value, int start, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] array = new byte[8];
			byte[] byteArrayFromByteArray = ByteArrayLib.GetByteArrayFromByteArray(value, start, 8);
			bool flag = byteArrayFromByteArray == null;
			byte[] result;
			if (flag)
			{
				result = null;
			}
			else
			{
				switch (dataFormat)
				{
				case DataFormat.ABCD:
					array[0] = byteArrayFromByteArray[7];
					array[1] = byteArrayFromByteArray[6];
					array[2] = byteArrayFromByteArray[5];
					array[3] = byteArrayFromByteArray[4];
					array[4] = byteArrayFromByteArray[3];
					array[5] = byteArrayFromByteArray[2];
					array[6] = byteArrayFromByteArray[1];
					array[7] = byteArrayFromByteArray[0];
					break;
				case DataFormat.BADC:
					array[0] = byteArrayFromByteArray[6];
					array[1] = byteArrayFromByteArray[7];
					array[2] = byteArrayFromByteArray[4];
					array[3] = byteArrayFromByteArray[5];
					array[4] = byteArrayFromByteArray[2];
					array[5] = byteArrayFromByteArray[3];
					array[6] = byteArrayFromByteArray[0];
					array[7] = byteArrayFromByteArray[1];
					break;
				case DataFormat.CDAB:
					array[0] = byteArrayFromByteArray[1];
					array[1] = byteArrayFromByteArray[0];
					array[2] = byteArrayFromByteArray[3];
					array[3] = byteArrayFromByteArray[2];
					array[4] = byteArrayFromByteArray[5];
					array[5] = byteArrayFromByteArray[4];
					array[6] = byteArrayFromByteArray[7];
					array[7] = byteArrayFromByteArray[6];
					break;
				case DataFormat.DCBA:
					array = byteArrayFromByteArray;
					break;
				}
				result = array;
			}
			return result;
		}

		/// <summary>
		/// 比较两个字节数组是否完全相同
		/// </summary>
		/// <param name="value1">字节数组1</param>
		/// <param name="value2">字节数组2</param>
		/// <returns>是否相同</returns>
		// Token: 0x06000024 RID: 36 RVA: 0x00002788 File Offset: 0x00000988
		[Description("比较两个字节数组是否完全相同")]
		public static bool GetByteArrayEquals(byte[] value1, byte[] value2)
		{
			bool flag = value1 == null || value2 == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				bool flag2 = value1.Length != value2.Length;
				if (flag2)
				{
					result = false;
				}
				else
				{
					for (int i = 0; i < value1.Length; i++)
					{
						bool flag3 = value1[i] != value2[i];
						if (flag3)
						{
							return false;
						}
					}
					result = true;
				}
			}
			return result;
		}

		/// <summary>
		/// 将单个字节转换成字节数组
		/// </summary>
		/// <param name="value">单个字节</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000025 RID: 37 RVA: 0x000027EC File Offset: 0x000009EC
		[Description("将单个字节转换成字节数组")]
		public static byte[] GetByteArrayFromByte(byte value)
		{
			return new byte[]
			{
				value
			};
		}

		/// <summary>
		/// 将Short类型数值转换成字节数组
		/// </summary>
		/// <param name="value">Short类型数值</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000026 RID: 38 RVA: 0x00002808 File Offset: 0x00000A08
		[Description("将Short类型数值转换成字节数组")]
		public static byte[] GetByteArrayFromShort(short value, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			byte[] array = new byte[2];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
			case DataFormat.CDAB:
				array[0] = bytes[1];
				array[1] = bytes[0];
				break;
			case DataFormat.BADC:
			case DataFormat.DCBA:
				array = bytes;
				break;
			}
			return array;
		}

		/// <summary>
		/// 将UShort类型数值转换成字节数组
		/// </summary>
		/// <param name="value">UShort类型数值</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000027 RID: 39 RVA: 0x0000285C File Offset: 0x00000A5C
		[Description("将UShort类型数值转换成字节数组")]
		public static byte[] GetByteArrayFromUShort(ushort value, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			byte[] array = new byte[2];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
			case DataFormat.CDAB:
				array[0] = bytes[1];
				array[1] = bytes[0];
				break;
			case DataFormat.BADC:
			case DataFormat.DCBA:
				array = bytes;
				break;
			}
			return array;
		}

		/// <summary>
		/// 将Int类型数值转换成字节数组
		/// </summary>
		/// <param name="value">Int类型数值</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000028 RID: 40 RVA: 0x000028B0 File Offset: 0x00000AB0
		[Description("将Int类型数值转换成字节数组")]
		public static byte[] GetByteArrayFromInt(int value, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			byte[] array = new byte[4];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
				array[0] = bytes[3];
				array[1] = bytes[2];
				array[2] = bytes[1];
				array[3] = bytes[0];
				break;
			case DataFormat.BADC:
				array[0] = bytes[2];
				array[1] = bytes[3];
				array[2] = bytes[0];
				array[3] = bytes[1];
				break;
			case DataFormat.CDAB:
				array[0] = bytes[1];
				array[1] = bytes[0];
				array[2] = bytes[3];
				array[3] = bytes[2];
				break;
			case DataFormat.DCBA:
				array = bytes;
				break;
			}
			return array;
		}

		/// <summary>
		/// 将UInt类型数值转换成字节数组
		/// </summary>
		/// <param name="value">UInt类型数值</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000029 RID: 41 RVA: 0x00002944 File Offset: 0x00000B44
		[Description("将UInt类型数值转换成字节数组")]
		public static byte[] GetByteArrayFromUInt(uint value, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			byte[] array = new byte[4];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
				array[0] = bytes[3];
				array[1] = bytes[2];
				array[2] = bytes[1];
				array[3] = bytes[0];
				break;
			case DataFormat.BADC:
				array[0] = bytes[2];
				array[1] = bytes[3];
				array[2] = bytes[0];
				array[3] = bytes[1];
				break;
			case DataFormat.CDAB:
				array[0] = bytes[1];
				array[1] = bytes[0];
				array[2] = bytes[3];
				array[3] = bytes[2];
				break;
			case DataFormat.DCBA:
				array = bytes;
				break;
			}
			return array;
		}

		/// <summary>
		/// 将Float数值转换成字节数组
		/// </summary>
		/// <param name="value">Float类型数值</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600002A RID: 42 RVA: 0x000029D8 File Offset: 0x00000BD8
		[Description("将Float数值转换成字节数组")]
		public static byte[] GetByteArrayFromFloat(float value, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			byte[] array = new byte[4];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
				array[0] = bytes[3];
				array[1] = bytes[2];
				array[2] = bytes[1];
				array[3] = bytes[0];
				break;
			case DataFormat.BADC:
				array[0] = bytes[2];
				array[1] = bytes[3];
				array[2] = bytes[0];
				array[3] = bytes[1];
				break;
			case DataFormat.CDAB:
				array[0] = bytes[1];
				array[1] = bytes[0];
				array[2] = bytes[3];
				array[3] = bytes[2];
				break;
			case DataFormat.DCBA:
				array = bytes;
				break;
			}
			return array;
		}

		/// <summary>
		/// 将Double类型数值转换成字节数组
		/// </summary>
		/// <param name="value">Double类型数值</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600002B RID: 43 RVA: 0x00002A6C File Offset: 0x00000C6C
		[Description("将Double类型数值转换成字节数组")]
		public static byte[] GetByteArrayFromDouble(double value, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			byte[] array = new byte[8];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
				array[0] = bytes[7];
				array[1] = bytes[6];
				array[2] = bytes[5];
				array[3] = bytes[4];
				array[4] = bytes[3];
				array[5] = bytes[2];
				array[6] = bytes[1];
				array[7] = bytes[0];
				break;
			case DataFormat.BADC:
				array[0] = bytes[6];
				array[1] = bytes[7];
				array[2] = bytes[4];
				array[3] = bytes[5];
				array[4] = bytes[2];
				array[5] = bytes[3];
				array[6] = bytes[0];
				array[7] = bytes[1];
				break;
			case DataFormat.CDAB:
				array[0] = bytes[1];
				array[1] = bytes[0];
				array[2] = bytes[3];
				array[3] = bytes[2];
				array[4] = bytes[5];
				array[5] = bytes[4];
				array[6] = bytes[7];
				array[7] = bytes[6];
				break;
			case DataFormat.DCBA:
				array = bytes;
				break;
			}
			return array;
		}

		/// <summary>
		/// 将Long类型数值转换成字节数组
		/// </summary>
		/// <param name="value">Long类型数值</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600002C RID: 44 RVA: 0x00002B48 File Offset: 0x00000D48
		[Description("将Long类型数值转换成字节数组")]
		public static byte[] GetByteArrayFromLong(long value, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			byte[] array = new byte[8];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
				array[0] = bytes[7];
				array[1] = bytes[6];
				array[2] = bytes[5];
				array[3] = bytes[4];
				array[4] = bytes[3];
				array[5] = bytes[2];
				array[6] = bytes[1];
				array[7] = bytes[0];
				break;
			case DataFormat.BADC:
				array[0] = bytes[6];
				array[1] = bytes[7];
				array[2] = bytes[4];
				array[3] = bytes[5];
				array[4] = bytes[2];
				array[5] = bytes[3];
				array[6] = bytes[0];
				array[7] = bytes[1];
				break;
			case DataFormat.CDAB:
				array[0] = bytes[1];
				array[1] = bytes[0];
				array[2] = bytes[3];
				array[3] = bytes[2];
				array[4] = bytes[5];
				array[5] = bytes[4];
				array[6] = bytes[7];
				array[7] = bytes[6];
				break;
			case DataFormat.DCBA:
				array = bytes;
				break;
			}
			return array;
		}

		/// <summary>
		/// 将ULong类型数值转换成字节数组
		/// </summary>
		/// <param name="value">ULong类型数值</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600002D RID: 45 RVA: 0x00002C24 File Offset: 0x00000E24
		[Description("将ULong类型数值转换成字节数组")]
		public static byte[] GetByteArrayFromULong(ulong value, DataFormat dataFormat = DataFormat.ABCD)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			byte[] array = new byte[8];
			switch (dataFormat)
			{
			case DataFormat.ABCD:
				array[0] = bytes[7];
				array[1] = bytes[6];
				array[2] = bytes[5];
				array[3] = bytes[4];
				array[4] = bytes[3];
				array[5] = bytes[2];
				array[6] = bytes[1];
				array[7] = bytes[0];
				break;
			case DataFormat.BADC:
				array[0] = bytes[6];
				array[1] = bytes[7];
				array[2] = bytes[4];
				array[3] = bytes[5];
				array[4] = bytes[2];
				array[5] = bytes[3];
				array[6] = bytes[0];
				array[7] = bytes[1];
				break;
			case DataFormat.CDAB:
				array[0] = bytes[1];
				array[1] = bytes[0];
				array[2] = bytes[3];
				array[3] = bytes[2];
				array[4] = bytes[5];
				array[5] = bytes[4];
				array[6] = bytes[7];
				array[7] = bytes[6];
				break;
			case DataFormat.DCBA:
				array = bytes;
				break;
			}
			return array;
		}

		/// <summary>
		/// 将Short数组转换成字节数组
		/// </summary>
		/// <param name="value">Short数组</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600002E RID: 46 RVA: 0x00002D00 File Offset: 0x00000F00
		[Description("将Short数组转换成字节数组")]
		public static byte[] GetByteArrayFromShortArray(short[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			ByteArray byteArray = new ByteArray();
			foreach (short value2 in value)
			{
				byteArray.Add(ByteArrayLib.GetByteArrayFromShort(value2, dataFormat));
			}
			return byteArray.array;
		}

		/// <summary>
		/// 将UShort数组转换成字节数组
		/// </summary>
		/// <param name="value">UShort数组</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600002F RID: 47 RVA: 0x00002D48 File Offset: 0x00000F48
		[Description("将UShort数组转换成字节数组")]
		public static byte[] GetByteArrayFromUShortArray(ushort[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			ByteArray byteArray = new ByteArray();
			foreach (ushort value2 in value)
			{
				byteArray.Add(ByteArrayLib.GetByteArrayFromUShort(value2, dataFormat));
			}
			return byteArray.array;
		}

		/// <summary>
		/// 将Int类型数组转换成字节数组
		/// </summary>
		/// <param name="value">Int类型数组</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000030 RID: 48 RVA: 0x00002D90 File Offset: 0x00000F90
		[Description("将Int类型数组转换成字节数组")]
		public static byte[] GetByteArrayFromIntArray(int[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			ByteArray byteArray = new ByteArray();
			foreach (int value2 in value)
			{
				byteArray.Add(ByteArrayLib.GetByteArrayFromInt(value2, dataFormat));
			}
			return byteArray.array;
		}

		/// <summary>
		/// 将UInt类型数组转换成字节数组
		/// </summary>
		/// <param name="value">UInt类型数组</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000031 RID: 49 RVA: 0x00002DD8 File Offset: 0x00000FD8
		[Description("将UInt类型数组转换成字节数组")]
		public static byte[] GetByteArrayFromUIntArray(uint[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			ByteArray byteArray = new ByteArray();
			foreach (uint value2 in value)
			{
				byteArray.Add(ByteArrayLib.GetByteArrayFromUInt(value2, dataFormat));
			}
			return byteArray.array;
		}

		/// <summary>
		/// 将Float类型数组转成字节数组
		/// </summary>
		/// <param name="value">Float类型数组</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000032 RID: 50 RVA: 0x00002E20 File Offset: 0x00001020
		[Description("将Float类型数组转成字节数组")]
		public static byte[] GetByteArrayFromFloatArray(float[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			ByteArray byteArray = new ByteArray();
			foreach (float value2 in value)
			{
				byteArray.Add(ByteArrayLib.GetByteArrayFromFloat(value2, dataFormat));
			}
			return byteArray.array;
		}

		/// <summary>
		/// 将Double类型数组转成字节数组
		/// </summary>
		/// <param name="value">Double类型数组</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000033 RID: 51 RVA: 0x00002E68 File Offset: 0x00001068
		[Description("将Double类型数组转成字节数组")]
		public static byte[] GetByteArrayFromDoubleArray(double[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			ByteArray byteArray = new ByteArray();
			foreach (double value2 in value)
			{
				byteArray.Add(ByteArrayLib.GetByteArrayFromDouble(value2, dataFormat));
			}
			return byteArray.array;
		}

		/// <summary>
		/// 将Long类型数组转换成字节数组
		/// </summary>
		/// <param name="value">Long类型数组</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000034 RID: 52 RVA: 0x00002EB0 File Offset: 0x000010B0
		[Description("将Long类型数组转换成字节数组")]
		public static byte[] GetByteArrayFromLongArray(long[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			ByteArray byteArray = new ByteArray();
			foreach (long num in value)
			{
				byteArray.Add(ByteArrayLib.GetByteArrayFromDouble((double)num, dataFormat));
			}
			return byteArray.array;
		}

		/// <summary>
		/// 将ULong类型数组转换成字节数组
		/// </summary>
		/// <param name="value">ULong类型数组</param>
		/// <param name="dataFormat">字节顺序</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000035 RID: 53 RVA: 0x00002EF8 File Offset: 0x000010F8
		[Description("将ULong类型数组转换成字节数组")]
		public static byte[] GetByteArrayFromULongArray(ulong[] value, DataFormat dataFormat = DataFormat.ABCD)
		{
			ByteArray byteArray = new ByteArray();
			foreach (ulong value2 in value)
			{
				byteArray.Add(ByteArrayLib.GetByteArrayFromULong(value2, dataFormat));
			}
			return byteArray.array;
		}

		/// <summary>
		/// 将指定编码格式的字符串转换成字节数组
		/// </summary>
		/// <param name="value">字符串</param>
		/// <param name="encoding">编码格式</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000036 RID: 54 RVA: 0x00002F40 File Offset: 0x00001140
		[Description("将指定编码格式的字符串转换成字节数组")]
		public static byte[] GetByteArrayFromString(string value, Encoding encoding)
		{
			return encoding.GetBytes(value);
		}

		/// <summary>
		/// 将16进制字符串按照空格分隔成字节数组
		/// </summary>
		/// <param name="value">16进制字符串</param>
		/// <param name="spilt">分隔符</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000037 RID: 55 RVA: 0x00002F5C File Offset: 0x0000115C
		[Description("将16进制字符串按照空格分隔成字节数组")]
		public static byte[] GetByteArrayFromHexString(string value, string spilt = " ")
		{
			value = value.Trim();
			List<byte> list = new List<byte>();
			byte[] result;
			try
			{
				bool flag = value.Contains(spilt);
				if (flag)
				{
					string[] array = value.Split(new string[]
					{
						spilt
					}, StringSplitOptions.RemoveEmptyEntries);
					foreach (string text in array)
					{
						list.Add(Convert.ToByte(text.Trim(), 16));
					}
				}
				else
				{
					list.Add(Convert.ToByte(value.Trim(), 16));
				}
				result = list.ToArray();
			}
			catch (Exception ex)
			{
				throw new ArgumentNullException("数据转换失败：" + ex.Message);
			}
			return result;
		}

		/// <summary>
		/// 将16进制字符串不用分隔符转换成字节数组（每2个字符为1个字节）
		/// </summary>
		/// <param name="value">16进制字符串</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000038 RID: 56 RVA: 0x00003018 File Offset: 0x00001218
		[Description("将16进制字符串不用分隔符转换成字节数组（每2个字符为1个字节）")]
		public static byte[] GetByteArrayFromHexStringWithoutSpilt(string value)
		{
			bool flag = value.Length % 2 != 0;
			if (flag)
			{
				throw new ArgumentNullException("检查字符串长度是否为偶数");
			}
			List<byte> list = new List<byte>();
			byte[] result;
			try
			{
				for (int i = 0; i < value.Length; i += 2)
				{
					string value2 = value.Substring(i, 2);
					list.Add(Convert.ToByte(value2, 16));
				}
				result = list.ToArray();
			}
			catch (Exception ex)
			{
				throw new ArgumentNullException("数据转换失败：" + ex.Message);
			}
			return result;
		}

		/// <summary>
		/// 将byte数据转换成一个Asii格式字节数组
		/// </summary>
		/// <param name="value">byte数据</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000039 RID: 57 RVA: 0x000030B0 File Offset: 0x000012B0
		[Description("将byte数据转换成一个Asii格式字节数组")]
		public static byte[] GetAsciiByteArrayFromValue(byte value)
		{
			return Encoding.ASCII.GetBytes(value.ToString("X2"));
		}

		/// <summary>
		/// 将short数据转换成一个Ascii格式字节数组
		/// </summary>
		/// <param name="value">short数据</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600003A RID: 58 RVA: 0x000030D8 File Offset: 0x000012D8
		[Description("将short数据转换成一个Ascii格式字节数组")]
		public static byte[] GetAsciiByteArrayFromValue(short value)
		{
			return Encoding.ASCII.GetBytes(value.ToString("X4"));
		}

		/// <summary>
		/// 将ushort数据转换成一个Ascii格式字节数组
		/// </summary>
		/// <param name="value">ushort数据</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600003B RID: 59 RVA: 0x00003100 File Offset: 0x00001300
		[Description("将ushort数据转换成一个Ascii格式字节数组")]
		public static byte[] GetAsciiByteArrayFromValue(ushort value)
		{
			return Encoding.ASCII.GetBytes(value.ToString("X4"));
		}

		/// <summary>
		/// 将string数据转换成一个Ascii格式字节数组
		/// </summary>
		/// <param name="value">string数据</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600003C RID: 60 RVA: 0x00003128 File Offset: 0x00001328
		[Description("将string数据转换成一个Ascii格式字节数组")]
		public static byte[] GetAsciiByteArrayFromValue(string value)
		{
			return Encoding.ASCII.GetBytes(value);
		}

		/// <summary>
		/// 将布尔数组转换成字节数组
		/// </summary>
		/// <param name="data">布尔数组</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600003D RID: 61 RVA: 0x00003148 File Offset: 0x00001348
		[Description("将布尔数组转换成字节数组")]
		public static byte[] GetByteArrayFromBoolArray(bool[] data)
		{
			bool flag = data == null || data.Length == 0;
			if (flag)
			{
				throw new ArgumentNullException("检查数组长度是否正确");
			}
			byte[] array = new byte[(data.Length % 8 != 0) ? (data.Length / 8 + 1) : (data.Length / 8)];
			for (int i = 0; i < array.Length; i++)
			{
				int num = (data.Length < 8 * (i + 1)) ? (data.Length - 8 * i) : 8;
				for (int j = 0; j < num; j++)
				{
					array[i] = ByteLib.SetbitValue(array[i], j, data[8 * i + j]);
				}
			}
			return array;
		}

		/// <summary>
		/// 将西门子字符串转换成字节数组
		/// </summary>
		/// <param name="value">西门子字符串</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600003E RID: 62 RVA: 0x000031EC File Offset: 0x000013EC
		[Description("将西门子字符串转换成字节数组")]
		public static byte[] GetByteArrayFromSiemensString(string value)
		{
			byte[] byteArrayFromString = ByteArrayLib.GetByteArrayFromString(value, Encoding.GetEncoding("GBK"));
			byte[] array = new byte[byteArrayFromString.Length + 2];
			array[0] = (byte)(byteArrayFromString.Length + 2);
			array[1] = (byte)byteArrayFromString.Length;
			Array.Copy(byteArrayFromString, 0, array, 2, byteArrayFromString.Length);
			return array;
		}

		/// <summary>
		/// 将欧姆龙CIP字符串转换成字节数组
		/// </summary>
		/// <param name="data">西门子字符串</param>
		/// <returns>字节数组</returns>
		// Token: 0x0600003F RID: 63 RVA: 0x00003238 File Offset: 0x00001438
		[Description("将欧姆龙CIP字符串转换成字节数组")]
		public static byte[] GetByteArrayFromOmronCIPString(string data)
		{
			byte[] byteArrayFromString = ByteArrayLib.GetByteArrayFromString(data, Encoding.ASCII);
			byte[] evenByteArray = ByteArrayLib.GetEvenByteArray(byteArrayFromString);
			byte[] array = new byte[evenByteArray.Length + 2];
			array[0] = BitConverter.GetBytes(array.Length - 2)[0];
			array[1] = BitConverter.GetBytes(array.Length - 2)[1];
			Array.Copy(evenByteArray, 0, array, 2, evenByteArray.Length);
			return array;
		}

		/// <summary>
		/// 扩展为偶数长度字节数组
		/// </summary>
		/// <param name="data">原始字节数据</param>
		/// <returns>返回字节数组</returns>
		// Token: 0x06000040 RID: 64 RVA: 0x00003294 File Offset: 0x00001494
		[Description("扩展为偶数长度字节数组")]
		public static byte[] GetEvenByteArray(byte[] data)
		{
			bool flag = data == null;
			byte[] result;
			if (flag)
			{
				result = new byte[0];
			}
			else
			{
				bool flag2 = data.Length % 2 != 0;
				if (flag2)
				{
					result = ByteArrayLib.GetFixedLengthByteArray(data, data.Length + 1);
				}
				else
				{
					result = data;
				}
			}
			return result;
		}

		/// <summary>
		/// 扩展或压缩字节数组到指定数量
		/// </summary>
		/// <param name="data">原始字节数据</param>
		/// <param name="length">指定长度</param>
		/// <returns>返回字节数组</returns>
		// Token: 0x06000041 RID: 65 RVA: 0x000032D4 File Offset: 0x000014D4
		[Description("扩展或压缩字节数组到指定数量")]
		public static byte[] GetFixedLengthByteArray(byte[] data, int length)
		{
			bool flag = data == null;
			byte[] result;
			if (flag)
			{
				result = new byte[length];
			}
			else
			{
				bool flag2 = data.Length == length;
				if (flag2)
				{
					result = data;
				}
				else
				{
					byte[] array = new byte[length];
					Array.Copy(data, array, Math.Min(data.Length, array.Length));
					result = array;
				}
			}
			return result;
		}

		/// <summary>
		/// 将字节数组转换成Ascii字节数组
		/// </summary>
		/// <param name="value">字节数组</param>
		/// <param name="segment">分隔符</param>
		/// <returns>ASCII字节数组</returns>
		// Token: 0x06000042 RID: 66 RVA: 0x00003320 File Offset: 0x00001520
		[Description("将字节数组转换成Ascii字节数组")]
		public static byte[] GetAsciiBytesFromByteArray(byte[] value, string segment = "")
		{
			return Encoding.ASCII.GetBytes(StringLib.GetHexStringFromByteArray(value, segment));
		}

		/// <summary>
		/// 将Ascii字节数组转换成字节数组
		/// </summary>
		/// <param name="value">ASCII字节数组</param>
		/// <returns>字节数组</returns>
		// Token: 0x06000043 RID: 67 RVA: 0x00003344 File Offset: 0x00001544
		[Description("将Ascii字节数组转换成字节数组")]
		public static byte[] GetBytesArrayFromAsciiByteArray(byte[] value)
		{
			return ByteArrayLib.GetByteArrayFromHexStringWithoutSpilt(Encoding.ASCII.GetString(value));
		}

		/// <summary>
		/// 将2个字节数组进行合并
		/// </summary>
		/// <param name="bytes1">字节数组1</param>
		/// <param name="bytes2">字节数组2</param>
		/// <returns>返回字节数组</returns>
		// Token: 0x06000044 RID: 68 RVA: 0x00003368 File Offset: 0x00001568
		[Description("将2个字节数组进行合并")]
		public static byte[] GetByteArrayFromTwoByteArray(byte[] bytes1, byte[] bytes2)
		{
			bool flag = bytes1 == null && bytes2 == null;
			byte[] result;
			if (flag)
			{
				result = null;
			}
			else
			{
				bool flag2 = bytes1 == null;
				if (flag2)
				{
					result = bytes2;
				}
				else
				{
					bool flag3 = bytes2 == null;
					if (flag3)
					{
						result = bytes1;
					}
					else
					{
						byte[] array = new byte[bytes1.Length + bytes2.Length];
						bytes1.CopyTo(array, 0);
						bytes2.CopyTo(array, bytes1.Length);
						result = array;
					}
				}
			}
			return result;
		}

		/// <summary>
		/// 将3个字节数组进行合并
		/// </summary>
		/// <param name="bytes1">字节数组1</param>
		/// <param name="bytes2">字节数组2</param>
		/// <param name="bytes3">字节数组3</param>
		/// <returns>返回字节数组</returns>
		// Token: 0x06000045 RID: 69 RVA: 0x000033C8 File Offset: 0x000015C8
		[Description("将3个字节数组进行合并")]
		public static byte[] GetByteArrayFromThreeByteArray(byte[] bytes1, byte[] bytes2, byte[] bytes3)
		{
			return ByteArrayLib.GetByteArrayFromTwoByteArray(ByteArrayLib.GetByteArrayFromTwoByteArray(bytes1, bytes2), bytes3);
		}

		/// <summary>
		/// 将字节数组中的某个数据修改
		/// </summary>
		/// <param name="sourceArray">字节数组</param>
		/// <param name="value">数据，确定好类型</param>
		/// <param name="start">开始索引</param>
		/// <param name="offset">偏移，布尔及字符串才起作用</param>
		/// <returns>返回字节数组</returns>
		// Token: 0x06000046 RID: 70 RVA: 0x000033E8 File Offset: 0x000015E8
		[Description("将字节数组中的某个数据修改")]
		public static byte[] SetByteArray(byte[] sourceArray, object value, int start, int offset)
		{
            string name = value.GetType().Name;
            byte[] array = null;
            switch (name.ToLower())
            {
                case "boolean":
                    Array.Copy(GetByteArrayFromByte(ByteLib.SetbitValue(sourceArray[start], offset, Convert.ToBoolean(value))), 0, sourceArray, start, 1);
                    break;
                case "byte":
                    Array.Copy(GetByteArrayFromByte(Convert.ToByte(value)), 0, sourceArray, start, 1);
                    break;
                case "int16":
                    Array.Copy(GetByteArrayFromShort(Convert.ToInt16(value)), 0, sourceArray, start, 2);
                    break;
                case "uint16":
                    Array.Copy(GetByteArrayFromUShort(Convert.ToUInt16(value)), 0, sourceArray, start, 2);
                    break;
                case "int32":
                    Array.Copy(GetByteArrayFromInt(Convert.ToInt32(value)), 0, sourceArray, start, 4);
                    break;
                case "uint32":
                    Array.Copy(GetByteArrayFromUInt(Convert.ToUInt32(value)), 0, sourceArray, start, 4);
                    break;
                case "single":
                    Array.Copy(GetByteArrayFromFloat(Convert.ToSingle(value)), 0, sourceArray, start, 4);
                    break;
                case "double":
                    Array.Copy(GetByteArrayFromDouble(Convert.ToDouble(value)), 0, sourceArray, start, 8);
                    break;
                case "int64":
                    Array.Copy(GetByteArrayFromLong(Convert.ToInt64(value)), 0, sourceArray, start, 8);
                    break;
                case "uint64":
                    Array.Copy(GetByteArrayFromULong(Convert.ToUInt64(value)), 0, sourceArray, start, 8);
                    break;
                case "byte[]":
                    array = GetByteArrayFromHexString(value.ToString());
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
                case "int16[]":
                    array = GetByteArrayFromShortArray(ShortLib.GetShortArrayFromString(value.ToString()));
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
                case "uint16[]":
                    array = GetByteArrayFromUShortArray(UShortLib.GetUShortArrayFromString(value.ToString()));
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
                case "int32[]":
                    array = GetByteArrayFromIntArray(IntLib.GetIntArrayFromString(value.ToString()));
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
                case "uint32[]":
                    array = GetByteArrayFromUIntArray(UIntLib.GetUIntArrayFromString(value.ToString()));
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
                case "single[]":
                    array = GetByteArrayFromFloatArray(FloatLib.GetFloatArrayFromString(value.ToString()));
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
                case "double[]":
                    array = GetByteArrayFromDoubleArray(DoubleLib.GetDoubleArrayFromString(value.ToString()));
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
                case "int64[]":
                    array = GetByteArrayFromLongArray(LongLib.GetLongArrayFromString(value.ToString()));
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
                case "uint64[]":
                    array = GetByteArrayFromULongArray(ULongLib.GetULongArrayFromString(value.ToString()));
                    Array.Copy(array, 0, sourceArray, start, array.Length);
                    break;
            }

            return sourceArray;
        }
	}
}
